﻿@{ ViewBag.Title = "荣誉资质";

    Layout = "~/Views/Shared/_HTMLLayout.cshtml"; }

<link rel="stylesheet" type="text/css" href='@Url.Content("~/css/sub.css")' />

<script>
    $(document).ready(function () {
        $(window).load(function () {
            $("nav a:nth-child(6)").addClass("onFocus")
        })
    })</script>

<dl class="honorPic"></dl>

<dl class="honor">
    <dt><img src='@Url.Content("~/img/sub/honor_title.jpg")'></dt>
    <dd>
        <div id="pageshow">

        </div>
    </dd>
</dl>
<dl class="knowledge">
    <dt></dt>
    <dd id="hornorlist">
    </dd>
</dl>
<div class="page" id="pageslist">
</div>


<script type="text/javascript">
    $(function () {
        initHonor();
        gethonorpages(1);
    });

    function initHonor() {
        var itemnumber = 4;
        var type = 6;
        var queryUrl = querybase + '/News/GetPageList' + '?NewsType=' + type + '&PageSize=' + itemnumber + '&PageIndex=1&Sort=BaseModifyTime';
        $.ajax({
            type: "GET",
            url: queryUrl,
            data: {},
            datatype: "json",
            success: function (data) {
                var items = data.Data;
                var htm = "";
                if (items != null && items != undefined) {
                    for (var i = 0; i < items.length; i++) {
                        htm += '<img src=\"' + items[i].ThumbImage + '\" />';
                    }

                    $("#pageshow").html(htm);
                }
            }
        });
    }

    function gethonorpages(pagenumber) {
        var itemnumber = 6;
        var type = 6;
        var queryUrl = querybase + '/News/GetPageList' + '?NewsType=' + type + '&PageSize=' + itemnumber + '&PageIndex=' + pagenumber + '&Sort=BaseModifyTime';
        $.ajax({
            type: "GET",
            async: false,
            url: queryUrl,
            data: {},
            datatype: "json",
            success: function (data) {
                var items = data.Data;
                var htm = "";
                for (var i = 0; i < items.length; i++) {

                    var show_date = getDate(items[i].BaseModifyTime);

                    htm += '<a href=\"\/home\/detail\/' + items[i].Id + '\">'
                        + '<div class=\"date\">' + show_date.getDate() + '<span>' + show_date.getFullYear() + '.' + show_date.getMonth() + '</span></div>'
                        + '<div class=\"content\">'
                        + '<h1>' + items[i].NewsTitle + '</h1>'
                        + '<p>' + items[i].NewsTag + '</p>'
                        + '</div>'
                        + '</a >';
                }


                var pageTotal = Math.ceil(data.Total / itemnumber);
                $("#hornorlist").html(htm);

                var htmpage = "<a href=\"#\" onclick=\"gethonorpages(1);\">首页<\/a>";
                if (pageTotal == 1) {
                    htmpage += "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\"><<<\/a>"
                        + "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\">>><\/a>";
                }
                else if ((pagenumber - 1) <= 0) {
                    htmpage += "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\"><<<\/a>"
                        + "<a href=\"#\" onclick=\"gethonorpages(" + (pagenumber + 1) + ");\">>><\/a>";
                }
                else if ((pagenumber + 1) >= pageTotal) {
                    htmpage += "<a href=\"#\" onclick=\"gethonorpages(" + (pageTotal - 1) + ");\"><<<\/a>"
                        + "<a href=\"javascript: return false;\"  style=\"cursor: default;\" style=\"opacity: 0.2\">>><\/a>";
                }
                htmpage += "<a href=\"#\" onclick=\"gethonorpages(" + pageTotal + ");\">尾页<\/a>";
                htmpage += "<span>第" + pagenumber + "页<\/span>";
                htmpage += "<span>共" + pageTotal + "页<\/span>";

                $("#pageslist").html(htmpage);
            }
        });
    }

    //字符串转日期格式，strDate要转为日期格式的字符串
    function getDate(strDate) {
        var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
            function (a) {
                return parseInt(a, 10) - 1;
            }).match(/\d+/g) + ')');
        return date;
    }



</script>